package com.neuedu.yyzx.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.yyzx.config.CommonResult;
import com.neuedu.yyzx.entity.EvaluationTemplate;
import com.neuedu.yyzx.service.IEvaluationTemplateService;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.management.Query;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 第7组....
 * @since 2021-04-28
 */
@RestController
@RequestMapping("//evaluationTemplate")
public class EvaluationTemplateController {

    @Autowired
    IEvaluationTemplateService evaluationTemplateService;

    @RequestMapping("/list")
    public CommonResult list(@RequestParam(defaultValue = "1") Integer pageNo , @RequestParam(defaultValue = "10") Integer pageSize, EvaluationTemplate evaluationTemplate){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("model_name",0);
        if(evaluationTemplate!=null && StringUtils.isNotEmpty(evaluationTemplate.getModelName())){
            queryWrapper.like("model_name",evaluationTemplate.getModelName());
        }

        return CommonResult.success(evaluationTemplateService.page(new Page<>(pageNo,pageSize),queryWrapper));

    }

    @RequestMapping("/toAdd")
    CommonResult toAdd(EvaluationTemplate evaluationTemplate){
        return CommonResult.success(evaluationTemplateService.saveOrUpdate(evaluationTemplate));
    }

    @RequestMapping("/update")
    CommonResult update(Integer id){
        return CommonResult.success(evaluationTemplateService.getById(id));
    }

    @RequestMapping("/del")
    CommonResult deleteById(Integer id) {
        return CommonResult.success((evaluationTemplateService.removeById(id)));
    }











}
